<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of user
 *
 * @author Janis
 */
class Model_Orm_User extends Orm\Model {
    protected static $_table_name = 'users';
    protected static $_primary_key = array('id');
    protected static $_properties = array(
	'id',
	'username' => array(
            'validation' => array('required'),
            'data_type' => 'varchar'
        ),
	'firstname' => array(
            'validation' => array('required'),
            'data_type' => 'varchar'
        ),
        'lastname' => array(
            'validation' => array('required'),
            'data_type' => 'varchar'
        ),
        'password' => array(
            'validation' => array('required'),
            'data_type' => 'varchar'
        ),
        'email' => array(
            'validation' => array('required'),
            'data_type' => 'varchar'
        ),
	'group' => array(
            'data_type' => 'int'
        ),
	'last_login' => array(
            'data_type' => 'varchar'
        ),
	'login_hash'
    );
    
    public static function validate($factory) {
	$validation = Validation::forge($factory);

	$validation->add_field('Username', 'Lietotājvārds', 'required|max_length[30]|min_length[3]');
        $validation->add_field('Firstname', 'Vārds', 'required|max_length[30]|min_length[2]');
        $validation->add_field('Lastname', 'Uzvārds', 'required|max_length[30]|min_length[2]');
        $validation->add_field('Email', 'E-pasts', 'required|max_length[255]|min_length[3]|valid_email');
        $validation->add_field('Password1', 'Parole', 'required|max_length[20]|min_length[3]');
        $validation->add_field('Password2', 'Parole atkārtoti', 'required|max_length[20]|min_length[3]');
        
	return $validation;
    }
}

?>
